/*
   @Copyright:LintCode
   @Author:   tjyemail
   @Problem:  http://www.lintcode.com/problem/maximum-depth-of-binary-tree
   @Language: C++
   @Datetime: 16-02-09 04:51
   */

/**
 * Definition of TreeNode:
 * class TreeNode {
 * public:
 *     int val;
 *     TreeNode *left, *right;
 *     TreeNode(int val) {
 *         this->val = val;
 *         this->left = this->right = NULL;
 *     }
 * }
 */

class Solution {
public:
	/**
	 * @param root: The root of binary tree.
	 * @return: An integer
	 */
	int maxDepth(TreeNode * root) {
		// write your code here
		if (root==NULL) return 0;
		return max(maxDepth(root->left), maxDepth(root->right))+1;
	}
};
